﻿// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License, See License.txt in the project root for license information.

using System.Diagnostics;
using NSQL.Sharpen;

namespace NSQL.Expressions.Functions
{
    public class CountFunction : BaseExpression, ICountFunction
    {
        public IExpression Expr { get; set; }
        public AggregateType AggregateType { get; set; }

        public CountFunction(IExpression expression, AggregateType type)
        {
            Expr = expression;
            AggregateType = type;
        }
        public override T Accept<T>(IExpressionVisitor<T> visitor) => visitor.FunctionVisitor.Visit(this);
        public override void Accept(IExpressionVisitor visitor) => visitor.Visit(this);
        public override bool IsValid => Expr.IsValid;
        protected override IExpression DeepCopy()
        {
            return new CountFunction(Expr.DeepClone(), AggregateType)
            {
                Tag = Tag
            };
        }
    }
}